<template>
  <div class="app-container">
    <!-- 机构概述、今日数据 -->
    <el-row :gutter="24" class="dashboard-row" justify="center">
      <el-col class="dashboard-col" :span="14">
        <el-card class="box-card institution">
          <p class="institutionalOverview">机构概述</p>
          <div class="content">
            <div class="left-content">
              <div class="name">神领管理员</div>
              <div class="address">地址：三河市流浪村</div>
              <div class="duty-people">负责人：可可帕</div>
              <div
                class="search-sales-department el-button el-button--warning is-plain"
                @click="showDepartment()"
              >
                查看营业部分布
              </div>
            </div>
            <div class="right-content">
              <div class="item">
                <div>
                  <div class="label">分拣中心(个)</div>
                  <div
                    class="num"
                    @click="
                      () => {
                        this.$router.push({ path: '/branches/organization-manage' });
                      }
                    "
                  >
                    300
                  </div>
                </div>
              </div>
              <div class="item">
                <div>
                  <div class="label">营业部(个)</div>
                  <div
                    class="num"
                    @click="
                      () => {
                        this.$router.push({ path: '/branches/organization-manage' });
                      }
                    "
                  >
                    300
                  </div>
                </div>
              </div>
              <div class="item">
                <div>
                  <div class="label">司机人数(个)</div>
                  <div
                    class="num"
                    @click="
                      () => {
                        this.$router.push({ path: '/branches/organization-manage' });
                      }
                    "
                  >
                    300
                  </div>
                </div>
              </div>
              <div class="item">
                <div>
                  <div class="label">快递员人数(个)</div>
                  <div
                    class="num"
                    @click="
                      () => {
                        this.$router.push({ path: '/branches/organization-manage' });
                      }
                    "
                  >
                    300
                  </div>
                </div>
              </div>
            </div>
          </div>
        </el-card>
      </el-col>
      <el-col :span="10" class="dashboard-col2">
        <el-card class="box-card right-info" body-style="{ paddingTop: '21px', minHeight: '60px' }">
          <div class="header">
            <p>今日数据</p>
          </div>
          <el-row :span="24" type="flex" class="row-bg" justify="space-around">
            <el-col :span="8">
              <div class="label">订单金额(元)</div>
              <div id="my-number1" class="value">499000</div>
              <div class="bottom active">较昨日 +10%</div>
            </el-col>
            <el-col :span="8">
              <div class="label">订单数量(笔)</div>
              <div id="my-number3" class="value">333</div>
              <div class="bottom active">较昨日 +10%</div>
            </el-col>
            <el-col :span="8">
              <div class="label">运输任务(次)</div>
              <div id="my-number4" class="value">2222</div>
              <div class="bottom active">较昨日 -10%</div>
            </el-col>
          </el-row>
        </el-card>
      </el-col>
    </el-row>
    <ECharts :options="chartOptions" height="400px" />
    <CopyButton :text="sampleText" />
  </div>
</template>

<script setup>
// 监听访问趋势日期范围的变化，重新获取趋势数据
// watch(
//   () => visitTrendDateRange.value,
//   (newVal) => {
//     console.log("Visit trend date range changed:", newVal);
//     fetchVisitTrendData();
//   },
//   { immediate: true }
// );
const sampleText = ref("这是一段要复制的示例文本");
// 柱状图配置
const chartOptions = ref({
  title: {
    text: "月度销售额统计",
    left: "center",
  },
  tooltip: {
    trigger: "axis",
    axisPointer: {
      type: "shadow",
    },
  },
  legend: {
    data: ["2023年", "2022年"],
    bottom: 10,
  },
  grid: {
    left: "3%",
    right: "4%",
    bottom: "15%",
    containLabel: true,
  },
  xAxis: {
    type: "category",
    data: ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"],
    axisLabel: {
      rotate: 45,
    },
  },
  yAxis: {
    type: "value",
    name: "销售额(万元)",
  },
  series: [
    {
      name: "2023年",
      type: "bar",
      data: [120, 132, 101, 134, 90, 230, 210, 182, 191, 234, 290, 330],
      itemStyle: {
        color: "#5470c6",
      },
    },
    {
      name: "2022年",
      type: "bar",
      data: [100, 110, 90, 120, 80, 200, 180, 160, 170, 200, 250, 300],
      itemStyle: {
        color: "#91cc75",
      },
    },
  ],
});
onMounted(() => {});
</script>

<style lang="scss" scoped>
//机构概述
.institution {
  .content {
    position: relative;
    display: flex;
    .left-content {
      padding-left: 10px;
      flex: 50%;
      border-right: 1px solid #ebeef5;
      .name {
        font-size: 16px;
        margin-top: 20px;
        margin-bottom: 13px;
      }
      .address {
        margin-bottom: 8px;
      }
      .duty-people {
        margin-bottom: 23px;
      }
      .address,
      .duty-people {
        font-size: 14px;
        color: #818693;
      }
      .search-sales-department {
        font-size: 14px;
        color: #e15536;
        width: 158px;
        height: 40px;
        background: #ffeeeb;
        border: 1px solid #f3917c;
        border-radius: 4px;
        display: flex;
        justify-content: center;
        align-items: center;
        cursor: pointer;
        .btn {
          display: flex;
          justify-content: center;
          align-items: center;
        }
        .btn::before {
          content: "";
          width: 20px;
          height: 20px;
          display: block;
          background-image: url("../../assets/position.png");
          background-repeat: no-repeat;
          background-size: contain;
        }
      }
    }
    .right-content {
      display: flex;
      flex: 50%;
      width: 300px;
      flex-wrap: wrap;
      .item {
        flex: 50%;
        flex-direction: column;
        align-items: center;
        display: flex;
        .label {
          font-size: 14px;
          // font-weight: bold;
          margin-bottom: 10px;
        }
        .num {
          font-size: 32px;
          font-weight: bold;
          color: #e15536;
          cursor: pointer;
        }
      }
      .item > div {
      }
      .item:nth-child(2) {
        padding-right: 25px;
      }
      .item:nth-child(1),
      .item:nth-child(2) {
        height: 85px;
      }
    }
    .line {
      position: absolute;
      height: 156px;
      width: 1px;
      background-color: #ebeef5;
      left: 330px;
    }
  }
}
.institutionalOverview {
  margin-top: 0;
}
.box-card {
  // padding: 5px 10px;
  p {
    font-size: 16px;
    font-weight: bold;
  }

  // 总销售额
  .total {
    font-size: 30px;
    height: 140px;
    line-height: 100px;
  }
  .trends {
    height: 22px;
    font-size: 14px;
    span {
      display: inline;
      i {
        color: red;
      }
    }
    span:last-child {
      margin-left: 20px;
      display: inline;
      i {
        color: green;
      }
    }
  }
  .chart {
    height: 160px;
  }
  .hr {
    border-top: 1px solid #e8e8e8;
    margin: 0px 0px 10px 0px;
  }
  .footer {
    span {
      font-size: 14px;
      line-height: 22px;
    }
    span:last-child {
      margin-left: 8px;
      color: rgba(0, 0, 0, 0.85);
    }
  }
  // 总销售额 end
}
// 订单总量样式覆盖
.cover-card ::v-deep .el-card__header {
  padding: 18px 20px;
  border-bottom: none;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
}
//今日数据
.right-info {
  .el-card__body {
    padding: 20px !important;
  }
  .row-bg {
    margin-top: 16px;
    padding-left: 10px;
    .el-col {
      display: flex;
      flex-direction: column;
      text-align: center;
    }
    .label {
      font-size: 14px;
      color: #20232a;
      margin-bottom: 21px;
    }
    .value {
      font-size: 30px;
      color: #20232a;
      font-weight: bold;
      margin-bottom: 24px;
    }
    .bottom {
      font-size: 14px;
      color: #818693;
      margin-bottom: 20px;
      display: flex;
      justify-content: center;
      padding-left: 9px;
    }
    .bottom::after {
      content: "";
      display: inline-block;
      width: 15px;
      height: 15px;
      background-image: url("../../assets/rise.png");
      background-repeat: no-repeat;
      background-size: contain;
    }
    .bottom.active::after {
      background-image: url("../../assets/down.png");
    }
  }
}
.dashboard-col2 {
  padding-left: 10px;
  padding-right: 20px;
}
</style>
